import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:get/get.dart';
import 'package:xiaomi_demo/src/modules/goodsContent/controllers/goods_content_controller.dart';
import 'package:xiaomi_demo/src/services/app_screenAdapter.dart';

class GoodsContentDetailsView extends GetView {
  @override
  final GoodsContentController controller = Get.find();
  final Function subHeader;

  GoodsContentDetailsView(this.subHeader, {super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      key: controller.gk1,
      color: Colors.white,
      width: double.infinity,
      child: Column(
        children: [subHeader(), _htmlWidget()],
      ),
    );
  }

  Widget _htmlWidget() {
    String? data;
    int index = controller.selectedTabsIndex.value;
    if (index == 0) {
      data = controller.model.value.content;
    } else if (index == 1) {
      data = controller.model.value.specs;
    } else if (index == 2) {
    } else {}

    return Html(
      shrinkWrap: true,
      data: data ?? "",
      style: {
        "body": Style(backgroundColor: Colors.white),
        "p": Style(
            backgroundColor: Colors.white,
            display: Display.inline,
            fontSize: FontSize(DoScreenAdapter.fs(12))),
        "span": Style(
            backgroundColor: Colors.white,
            fontSize: FontSize(DoScreenAdapter.fs(12))),
        "br": Style(backgroundColor: Colors.white, display: Display.none)
      },
    );
  }
}
